CS 211 Lesson 30

GUI Components

Quote:

"I don't know whether this is the best of times or the worst of times, but I assure you it's the only time you've got." Art Buchwald

Lesson Objectives:

Lesson:

I. MATLAB Concepts

A. Storing data within a GUI

B. Initializing a GUI program

handles.output = hObject;

% put your GUI initialization code here

guidata(hObject, handles):

C. Getting and setting GUI object properties

User_selected_value = get(handles.Temperature, 'Value');

set(handles.Temperature, 'Min', 0)

D. Key properties of GUI Components

Component type Property Description
static text
 
'Style'
'String'
'text'
the displayed text
edit box
 
'Style'
'String'
'Min'
'Max'
'edit'
the text that a user enters into the edit box
the minimum number of lines of text the user can enter
the maximum number of lines of text the user can enter
push button
 
'Style'
'String'
'pushbutton'
the text on the button
toggle button
 
'Style'
'Value'
'togglebutton
is set to the value of Max (1 by default) when the button is on
is set to the value of Min (0 by default) when the button is off
check box
 
'Style'
'Value'
'checkbox'
is set to the value of Max (1 by default) when the box is checked
is set to the value of Min (0 by default) when the box is unchecked
radio button
 
'Style'
'Value'
'radiobutton'
is set to the value of Max (1 by default) when the button is selected (has a dot in it)
is set to the value of Min (0 by default) when the button is not selected
popup menu
 
'Style'
'String'
'Value'
'popupmenu'
a cell array of strings, one for each menu option
a scalar set to the number of the user selected menu option
list box
 
'Style'
'String'
'Value'
'SelectionType'
'SelectionType'
'listbox'
is a cell array of strings, one for each line in the list box
is a vector containing the numbers of the user-selected lines
is set to 'normal' if the user single clicks in a list box
is set to 'open' if the user double clicks in a list box
slider
 
'Style'
'Value'
'Min'
'Max'
'SliderStep'
'slider'
is set to a value corresponding to the user-selected slider position
the minimum slider value
the maximum slider value
a 2-element row vector that determines how much the slider moves (the first element value is the percentage of slider movement when the user clicks an arrow button; the second element value is the percentage of slider movement when the user clicks in the slider trough which is right or left of the slider button position).

E. Panels and Button Groups

II. Good Programming Practices

III. Algorithms

Lab Work: Lab 30

References:  Chapman Textbook: section 10.2-10.5